<template>
  <div>
    <q-btn
      v-if="params?.data.exeCrane != '02'"
      :label="button"
      @click="confirm(button)"
      style="color: #fff; background-color: #dbb22e; height: 30px; width: 70px; font-size: 10px"
    />
  </div>
</template>

<script lang="ts">
import { api } from 'src/boot/api';
import { defineComponent, computed, PropType } from 'vue';

export default defineComponent({
  name: 'confirm-button',

  props: {
    params: {
      type: Object as PropType<{ data: any }>,
    },
  },

  setup(props) {
    const button = computed(() => {
      if (props.params?.data.orderStatus == '11') {
        return '取消选中';
      } else if (props.params?.data.orderStatus == '1' || props.params?.data.orderStatus == '2') {
        return '选中';
      } else {
        return '';
      }
    });

    const confirm = async (val: any) => {
      if (val == '选中') {
        await api.get(
          `/ManalController/CraneOrderOperate?craneNo=1&orderNo=${props.params?.data.orderNo}&operType=3&currentPos=${props.params?.data.frPos}`,
        );
      } else {
        await api.get(
          `/ManalController/CraneOrderOperate?craneNo=1&orderNo=${props.params?.data.orderNo}&operType=4&currentPos=${props.params?.data.frPos}`,
        );
      }
    };
    return { button, confirm };
  },
});
</script>
